﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CoderJoe.WoW.GearManager.Views;
using Microsoft.Practices.Unity;

namespace CoderJoe.WoW.GearManager
{
    public class LoadCharacterController
        : Controller
    {
        public LoadCharacterController(Workspace workspace)
            : base(workspace)
        {
        }

        internal void Show()
        {
            using(IUnityContainer child = Workspace.CreateChildContainer())
            {
                child.RegisterInstance(this);
                child.RegisterType<LoadCharacterModel>(new ContainerControlledLifetimeManager());

                LoadFromArmoryView view = child.Resolve<LoadFromArmoryView>();
				view.ShowDialog();
            }
        }

		internal void LoadCharacter(LoadCharacterModel Model)
		{
			CharacterController controller = Workspace.Resolve<CharacterController>();
			controller.Load(Model.Realm, Model.Name);
		}
	}
}
